package com.stqf.scala.grammar

import com.stqf.scala.utils.ProUtils
import java.sql.Timestamp
import scala.beans.BeanProperty

case class Super(var name: String, var address: String)

class Father() {
  @BeanProperty var name: String = _
  @BeanProperty var age: Int = _
  @BeanProperty var both: Timestamp = _

  def this(name: String, age: Int) {
    this()
    this.age = age
    this.name = name
  }

  override def toString: String = s"name is $name, age is $age"
}

object Hello {
  type Daddy = Father
  implicit var word: String = "万岁万岁万万岁"
  implicit var value: String = "九千九百九十九岁"

  def main(args: Array[String]): Unit = {
    println("Hello Grammar")
    val str = "%s is GRD".format("China")
    println(str)
    val sp = Super("中国", "亚洲")
    println(sp)

    val fa = new Father()
    val fax = new Father("Tom", 15)
    val daddy = new Daddy("Tom", 18)
    printf("fa: %s %n", fa)
    printf("fax: %s %n", fax)
    printf("daddy: %s %n", daddy)
    fax.ensuring(item => item.name.equals("Tom"))

    val tr = s"${sp.name} en"
    println("字符串占位符之一: " + tr)
    val name = "John"
    val ss = s"""$name is Chins"""
    println("字符串占位符之二: " + ss)


    def wordVerify(implicit value: String): String = {
      s"implicit value is $value"
    }

    println(wordVerify(value))

    println(ProUtils.isBlank(null))

  }
}
